#!/usr/local/bin/python3
# -*- coding: UTF-8 -*-
"""
@author:apple
@file:PriorityQueue.py
@time:2021/07/26
"""


class PriorityQueue:
    ...
    import heapq

    class Node:
        ...

        def __init__(self, val, priorityVal):
            ...
            self.val = val
            self.priorityVal = priorityVal

        def __gt__(self, other):
            return self.priorityVal < other.priorityVal

    def __init__(self):
        ...
        self.container = []

    def push(self, val, priorityVal):
        ...
        node = PriorityQueue.Node(val, priorityVal)
        PriorityQueue.heapq.heappush(self.container, node)

    def pop(self):
        ...
        return PriorityQueue.heapq.heappop(self.container).val

    def peek(self):
        ...
        return self.container[0].val

    def empty(self):
        if self.container is None:
            return True
        return len(self.container) == 0


if __name__ == '__main__':
    pass
    priQueue = PriorityQueue()
    priQueue.push(1, 12)
    priQueue.push(2, 23)
    priQueue.push(3, 13)
    priQueue.push(6, 13)
    priQueue.push(4, 15)
    # print(priQueue.peek())

    while not priQueue.empty():
        ...
        print(priQueue.pop())
